obj = k2l.o
CFLAGS += -Wall -D_K2L_MAIN

ifeq ($(o3),y)
CFLAGS += -O3
endif
ifeq ($(gperf),y)
obj += k2l_gperf.o
CFLAGS += -D_K2L_USE_GPERF
endif

.PHONY: all clean len

all: k2l

k2l: $(obj)
	$(CC) -o $@ $^ $(CFLAGS)

k2l.o: k2l.h

%.o: %.c
	$(CC) -c $< $(CFLAGS)

k2l_gperf.c: k2l.gperf
	gperf -I -t k2l.gperf >$@

clean:
	rm -f k2l
	rm -f *.o
	rm -f k2l_gperf.c

len:
	wc -l k2l.[ch]
